package com.drink.yan.web.rest;

import com.drink.yan.intf.entity.YanActivity;
import com.drink.yan.intf.entity.YanSku;
import com.drink.yan.intf.vo.SkuVo;
import com.drink.yan.svc.service.YanSkuService;
import com.drink.yan.web.rest.req.cmd.ChangeSkuStatusCmd;
import com.drink.yan.web.rest.req.qry.PageCourseSkuQry;
import com.drink.yan.web.rest.req.qry.PageSkuQry;
import com.drink.yan.web.rest.req.qry.PageStudySkuQry;
import com.meta.act.app.service.ISysNoticeService;
import com.meta.framework.common.core.controller.BaseController;
import com.meta.framework.common.core.page.TableDataInfo;
import com.meta.framework.common.core.page.TableResponseVo;
import com.meta.framework.core.ResponseVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * java类简单作用描述
 *
 * @Title:
 * @Package: com.drink.yan.web.rest.app.
 * @Author: M.simple
 * @Remark: The modified content
 * @CreateDate: 2023/11/23 14:58
 * @Version: v2.0
 */
@RestController
@RequestMapping("/sku")
public class SkuRest extends BaseController {

    @Resource
    private YanSkuService yanSkuService;

    @ApiOperation(value = "获取体验课,可传 queryType", notes = "获取体验课", tags = {"学生小程序"})
    @GetMapping("list/course")
    public TableResponseVo<List<SkuVo>> listCourseSku(PageCourseSkuQry qry){
        if("hot".equals(qry.getQueryType())){
            qry.setPageSize(2);
        }
        startPage();
        List<SkuVo> list = yanSkuService.listCourseSku(qry);
        return getResponseVoTable(list);
    }

    @ApiOperation(value = "SKU列表", notes = "SKU列表", tags = {"学生小程序","PC"})
    @GetMapping("list")
    public TableResponseVo<List<SkuVo>> list(PageSkuQry qry){
        startPage();
        List<SkuVo> list = yanSkuService.listSku(qry);
        return getResponseVoTable(list);
    }

    @ApiOperation(value = "获取学习资料", notes = "获取学习资料", tags = {"学生小程序"})
    @GetMapping("list/study")
    public TableResponseVo<List<SkuVo>> listStudySku(PageStudySkuQry qry){
        startPage();
        List<SkuVo> list = yanSkuService.listStudySku(qry);
        return getResponseVoTable(list);
    }

    @ApiOperation(value = "商品详情", notes = "商品详情", tags = {"学生小程序"})
    @GetMapping("/detail/{skuId}")
    public ResponseVo<YanSku> getSkuDetail(@PathVariable Long skuId){
        return ResponseVo.success(yanSkuService.getSkuDetail(skuId));
    }

    @ApiOperation(value = "保存商品", notes = "保存商品", tags = {"PC"})
    @PostMapping("/save")
    public ResponseVo<YanSku> saveSku(@RequestBody YanSku yanSku){
        return ResponseVo.success(yanSkuService.saveSku(yanSku));
    }

    @ApiOperation(value = "商品状态流转:审核不通过", notes = "商品状态流转：审核不通过", tags = {"PC"})
    @PostMapping("/status/check/fail")
    public ResponseVo<YanSku> statusCheckFail(@RequestBody ChangeSkuStatusCmd cmd){
        return ResponseVo.success(yanSkuService.statusCheckFail(cmd));
    }

    @ApiOperation(value = "商品状态流转:审核通过", notes = "商品状态流转：审核通过", tags = {"PC"})
    @PostMapping("/status/check/succ")
    public ResponseVo<YanSku> statusCheckSucc(@RequestBody ChangeSkuStatusCmd cmd){
        return ResponseVo.success(yanSkuService.statusCheckSucc(cmd));
    }

    @ApiOperation(value = "商品状态流转:上架", notes = "商品状态流转：上架", tags = {"PC"})
    @PostMapping("/status/onShelf")
    public ResponseVo<YanSku> statusOnShelf(@RequestBody ChangeSkuStatusCmd cmd){
        return ResponseVo.success(yanSkuService.statusOnShelf(cmd));
    }

    @ApiOperation(value = "商品状态流转:下架", notes = "商品状态流转：下架", tags = {"PC"})
    @PostMapping("/status/offShelf")
    public ResponseVo<YanSku> statusOffShelf(@RequestBody ChangeSkuStatusCmd cmd){
        return ResponseVo.success(yanSkuService.statusOffShelf(cmd));
    }

    @ApiOperation(value = "删除商品", notes = "删除商品", tags = {"PC"})
    @DeleteMapping("/delete/{skuId}")
    public ResponseVo<Boolean> deleteSku(@PathVariable("skuId") Long skuId){
        return ResponseVo.success(yanSkuService.deleteSku(skuId));
    }


}
